/*
  学习目标：Route组件使用说明

*/
import React from 'react';
import { BrowserRouter as Router, Route, NavLink } from 'react-router-dom';
import './index.css';

export default class App extends React.Component {
  render() {
    return (
      <Router>
        <div>
          <h1>app组件</h1>
          <NavLink to="/home" exact>
            调到home
          </NavLink>
          <br />
          <NavLink to="/my">调到我的音乐</NavLink>
          <br />
          <NavLink to="/friend">调到朋友</NavLink>
          {/* 1. 💥Route默认从上向下依次匹配, 不会主动停止 */}
          {/* 2. Route组件是规则对象和挂载点二合一 */}
          {/* 3. Route组件未匹配上, 最终渲染一个null */}
          <Route path="/home" component={Home}></Route>
          <Route path="/home" component={Home}></Route>
          <Route path="/home" component={Home}></Route>
          <Route path="/home" component={Home}></Route>
          <Route path="/my" component={MyMusic}></Route>
          <Route path="/friend" component={Friend}></Route>
          {/* 4.💥 匹配任意路径的两种方式 */}
          {/* 4.1 不写path, 类似vue中的*, 此时设置exact无效 */}
          <Route component={MyMusic} exact></Route>
          {/* 4.2 path="/" 表示跟任意的路径可以模糊匹配 */}
          <Route path="/" component={MyMusic}></Route>

          {/* 5. Route默认是模糊匹配, exact表示精准匹配 */}
          <Route path="/" component={MyMusic} exact></Route>
        </div>
      </Router>
    );
  }
}

function Home() {
  return <h1>我是首页组件</h1>;
}

function MyMusic() {
  return <h1>我是我的音乐件</h1>;
}

function Friend() {
  return <h1>我是朋友组件</h1>;
}
